package com.skywork;

import javax.sql.DataSource;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import com.spring4all.swagger.EnableSwagger2Doc;

/**
 * @author leiyan
 * @date 2016年12月23日 下午3:38:46
 */

@EnableAsync
@EnableCaching
@EnableSwagger2Doc
@SpringBootApplication
public class Application {

	public static void main(String[] args) {
		SpringApplicationBuilder app = new SpringApplicationBuilder(Application.class).web(true);
		app.run(args);
	}
	

	@Bean
	public LocalValidatorFactoryBean validate(){
		LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
		return validator;
	}
	
	
	@Bean
	@Primary
	public DataSource dataSourceOne(){
	    return DruidDataSourceBuilder.create().build();
	}
}
